package com.java.huxb.day01;

/**
 * @author huxb
 * @date 2020/2/26 0026 下午 2:25
 */
public class ThreadDemo01 {
    public static void main(String[] args) {
        Thread thread3 = new Thread(() -> {

            for (int i = 0; i < 10; i++) {
                System.out.println("thread3 --- " + i);
            }
        });

        Thread thread2 = new Thread(() -> {
            try {
                thread3.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            for (int i = 0; i < 10; i++) {
                System.out.println("thread2 --- " + i);
            }
        });


      Thread thread1 = new Thread(() -> {
          try {
              thread2.join();
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
          for (int i = 0; i < 10; i++) {
              System.out.println("thread1 --- " + i);
          }
      });

      thread1.start();
      thread2.start();
      thread3.start();


    }
}
class  CreatedTeread01 extends  Thread{

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(i);
        }
    }
}

class CreatedThread02 implements  Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("runnable" + i);
        }

        System.out.println(Thread.currentThread().getName());
        System.out.println("---------------------------------------");
    }
}



